home *** CD-ROM | disk | FTP | other *** search
- Path: news.sunquest.com!kitk!kitk
- From: kitk@mudshark.sunquest.com (Kit Kauffmann)
- Newsgroups: comp.lang.c++
- Subject: Re: Instantiate Forward Declared Class
- Date: Fri, 15 Mar 1996 14:35:45
- Organization: Sunquest
- Message-ID: <kitk.2137.000E9904@mudshark.sunquest.com>
- References: <DoAu1u.Lxx@news.uwindsor.ca>
- NNTP-Posting-Host: kkauffma.sunquest.com
- Keywords: Forward declaration
- X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]
-
- In article <DoAu1u.Lxx@news.uwindsor.ca> saed@engn.uwindsor.ca (Saed Aryan,13325,1100,g) writes:
- >From: saed@engn.uwindsor.ca (Saed Aryan,13325,1100,g)
- >Subject: Instantiate Forward Declared Class
- >Keywords: Forward declaration
- >Date: Fri, 15 Mar 1996 07:56:17 GMT
-
- >Hi All,
-
- >--- How do you instantiate a class that has not yet been defined but has been
- > forward declared?
-
- >e.g. how do you implement the following:
-
- >class A { public : AMethod(B bObj){}; };
- >class B { public : BMethod(A aObj){}; };
-
- >compiling this will result in an error message telling that A and B are not known.
- >But when froward declaring A and B as in "class A; class B;" before the two lines
- >above, the error message becomes: parameters bObj and aObj are incomplete types.
-
- >Apparently it is not possible to instantiate a declared but not yet defined class.
-
- >The answer to this question will also answer my previous question (143815)
- >From saed@engn.uwindsor.ca
- >Subject: error: undef. but decl. template as member
- >Date: Wed, 13 Mar 1996 02:14:38 GMT
-
- >Thanks in advance,
- >Aryan.
-
-
- Of course you can't - the compiler doesn't know how big the object is. But
- you can always use pointers to "unknown" objects to solve problems like this
- (AFAIK :)
-
- HTH!
-
-
- Kit Kauffmann - kitk@mudshark.sunquest.com
- AKA 73363,447 (Compu$erve)
-
- Finger me for my public key
-